package Entity;

/**
 * 习题实体类：统一习题ID生成规则，避免ID格式不一致
 */
public class Exercise {
    private String exerciseId;
    private int num1;
    private char operator;
    private int num2;
    private int correctAnswer;

    // 构造函数（强制按统一格式生成习题ID）
    public Exercise(String type, String date, String seq, int questionNo, int num1, char operator, int num2, int correctAnswer) {
        if (type == null || date == null || seq == null) {
            throw new IllegalArgumentException("习题ID生成参数不能为空");
        }
        // 统一习题ID格式：类型_日期_序号_题号（如 Add_20231001_001_001）
        this.exerciseId = String.format("%s_%s_%s_%03d", type, date, seq, questionNo);
        this.num1 = num1;
        this.operator = operator;
        this.num2 = num2;
        this.correctAnswer = correctAnswer;
    }

    // Getter方法（禁止外部修改习题ID，确保一致性）
    public String getExerciseId() { return exerciseId; }
    public int getNum1() { return num1; }
    public char getOperator() { return operator; }
    public int getNum2() { return num2; }
    public int getCorrectAnswer() { return correctAnswer; }
}